package nfa_generator;

import java.util.List;
import java.util.ArrayList;

public class NFAGraph {
	private NFANode startState;
	private NFANode endState;
	private List<NFANode> states;
	private List<NFANode> finalEndStates;
	
	/**
	 * Empty constructor for NFAGraph, initializes states to null and creates an empty states list.
	 */
	public NFAGraph() {
		this.setStartState(null);
		this.setEndState(null);
		this.states = new ArrayList<NFANode>();
		this.finalEndStates = new ArrayList<NFANode>();
	}
	
	/**
	 * Constructor for NFAGraph, takes in start state and end state NFANodes. Adds them to it's list of states.
	 * @param startState
	 * @param endState
	 */
	public NFAGraph(NFANode startState) {
		this.setStartState(startState);
		this.setEndState(null);
		this.states = new ArrayList<NFANode>();
		this.finalEndStates = new ArrayList<NFANode>();
		states.add(startState);
	}
	
	/**
	 * Constructor for NFAGraph, takes in start state and end state NFANodes. Adds them to it's list of states.
	 * @param startState
	 * @param endState
	 */
	public NFAGraph(NFANode startState, NFANode endState) {
		this.setStartState(startState);
		this.setEndState(endState);
		this.states = new ArrayList<NFANode>();
		this.finalEndStates = new ArrayList<NFANode>();
		states.add(startState);
		states.add(endState);
	}
	
	/**
	 * Getter for start state.
	 * @return
	 */
	public NFANode getStartState() {
		return startState;
	}
	
	/**
	 * Setter for start state.
	 * @param startState
	 */
	public void setStartState(NFANode startState) {
		this.startState = startState;
	}

	/**
	 * Getter for end state.
	 * @return
	 */
	public NFANode getEndState() {
		return endState;
	}
	
	/**
	 * Setter for end state.
	 * @param endState
	 */
	public void setEndState(NFANode endState) {
		this.endState = endState;
	}
	
	/**
	 * Getter for the states in the graph.
	 * @return
	 */
	public List<NFANode> getStates() {
		return states;
	}
	
	/**
	 * Setter for the list of states in the graph.
	 * @param states
	 */
	public void setStates(List<NFANode> states) {
		this.states = states;
	}
	
	/**
	 * Takes in a list of states and adds it to the current list of states in the graph.
	 * @param states
	 */
	public void addStates(List<NFANode> states) {
		this.states.addAll(states);
	}
	
	/**
	 * Takes in a state and adds it to the list of states in the graph.
	 * @param state
	 */
	public void addState(NFANode state) {
		this.states.add(state);
	}
	
	/**
	 * Getter for the end states of the final NFAGraph that is returned from the generator.
	 * @return
	 */
	public List<NFANode> getFinalEndStates() {
		return finalEndStates;
	}

	/**
	 * Setter for the end states of the final NFAGraph that is returned from the generator.
	 * @param finalEndStates
	 */
	public void setFinalEndStates(List<NFANode> finalEndStates) {
		this.finalEndStates = finalEndStates;
	}
	
	/**
	 * Adds a state to the final end states list.
	 * @param finalEndState
	 */
	public void addFinalEndState(NFANode finalEndState) {
		this.finalEndStates.add(finalEndState);
	}
}